<template>
  <dymic-table v-if="show" v-bind="config" />
</template>
<script setup lang="ts">
import DymicTable from '../../../../components/DymicTable.vue';
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
const config = ref<{
  name: string;
  api: any;
  fields: any[];
  pagination?: any;
  actions?: any;
  tableConfig?: any;
  tableOperater?: any;
  formConfig?: any;
}>({
  name: '',
  api: {},
  fields: [],
  pagination: {}
});
const show = ref(false);
const loadConfig = async () => {
  const { configname } = route.query;
  console.log(configname);
  const res = await import(`../../config/list/${configname}.ts`);
  config.value = res.default;
  show.value = true;
};

watch(
  () => route.path,
  () => {
    loadConfig();
    console.log('path change');
  },
  { deep: true, immediate: true }
);

const onSubmit = () => {
  console.log('submit!');
};
</script>
